package tezhongbing.socket;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;

public class SocketWraper {
	private Socket socket;
	private BufferedReader reader;
	private BufferedWriter writer;
	
	public SocketWraper(Socket socket) throws IOException{
		this.socket = socket;
		this.reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		this.writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
	}
	
	public String readLine() throws IOException{
		return reader.readLine();
	}
	
	public void writeLine(String line) throws IOException{
		writer.write(line);
		writer.newLine();
		writer.flush();
	}
	
	public void close() throws IOException{
		if(socket != null)
			socket.close();
	}
	
}
